<?php
class Jingdian extends Base_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('jingdian_model');
        $this->load->model('city_model');
	    $this->load->model('comment_model');
	}


    public function getlist()
    {
        $data = $_GET;
        $re = $this->jingdian_model->getlist($data);
        $this->success($re);
    }

    public function detail()
    {
    	if(is_numeric($_GET['id']) && $_GET['id']>0){
    		$id = $_GET['id'];
    	}else{
    		$id = 0;
    	}
        if(!empty($id)){
        	$data = $this->jingdian_model->detail($id);
        	//评论信息
        	$con_data['id'] = $id;
        	$con_data['limit'] = 5;
        	$con_data['offset'] = 0;
        	$coms = $this->comment_model->getJingdianComments($con_data);
        	$data['coms']=$coms;
        }else{
        	$data='';
        }
        
        $this->success($data);

    }

    /**
     * 获取景点标签
     */
    public function gettag()
    {
		if(!empty($_GET['cityId'])&&is_numeric($_GET['cityId'])&&$_GET['cityId']>0)
		  {$cityId= $_GET['cityId'];}
		else
		  {$cityId=0;}
        $data = $this->city_model->getcitytype($cityId);
        $this->success($data);
    }
	
	/**
	** 获取更多景点评价
	**/
	public function getComments()
	{
		//景点id
	    if(empty($_GET['id'])||!is_numeric($_GET['id'])||$_GET['id']<0)
	    {$this->error('id is null');}
		$id = $_GET['id'];
		//分页参数
		if(empty($_GET['page'])||!is_numeric($_GET['page'])||$_GET['page']<0)
		    $page = 1;
		else
			$page = $_GET['page'];
																		    
		$limit=$page*5;
		$offset=0;
		//评论
		$con_data['id'] = $id;
		$con_data['limit'] = $limit;
		$con_data['offset'] = $offset;
		$coms = $this->comment_model->getJingdianComments($con_data);
		$this->success($coms);
	}

}
